<?php 
	// require_once("./system/loginCheck.php");
	 ?>

	<?php
	require_once("./system/loginCheck.php");
    require_once("../congfig/config.php");
    


	$oldpw=$_POST["oldpasswd"];
	$npw=$_POST["passwd"];
	$npw1=$_POST["veriypasswd"];
	

	//取数据库中的原密码
	$student=$_SESSION['username'];
	$sql="select passwd from users where username='$student'";
	$result=$conn->query($sql);//结果集
	$row=$result->fetch_array();

	if (strcmp(md5($oldpw), $row["passwd"])!=0) {//比对数据库中取得的密码和表单输入的密码
		header("location:owner-changePass.php?text=原密码输入错误!");
	}
    elseif (strcmp($npw, $npw1)) {
		header("location:owner-changePass.php?text=两次密码输入不同");
	}
	else{
		$sql1="update users set passwd=md5('$npw') where username='$student'";
		$result1=$conn->query($sql1);//整型
		if ($result1==1) {
			$text="修改密码成功";
			header("location:owner-changePass.php?text=$text");
			
		}
		else{
			echo "失败";
		}

	}

		?>